package com.ocean.courtyard.message;

import com.ocean.courtyard.constants.ConstantsAttribute;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;

public class Message {

    private final FileConfiguration config;
    private final FileConfiguration messageConfig;

    public Message(FileConfiguration config, FileConfiguration messageConfig) {
        this.config = config;
        this.messageConfig = messageConfig;
    }

    public void sendMaxHomesLimitMessage(Player player) {
        Integer max = config.getInt(ConstantsAttribute.MAX_HOMES);
        String message = messageConfig.getString(ConstantsAttribute.MAX_HOMES_LIMIT);
        String format = String.format(message, max);
        player.sendMessage(Component.text(format, NamedTextColor.RED));
    }

    public void sendWorldImportSuccessMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.WORLD_IMPORT_SUCCESS);
        player.sendMessage(Component.text(message, NamedTextColor.GREEN));
    }

    public void sendWorldImportFailureMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.WORLD_IMPORT_FAILURE);
        player.sendMessage(Component.text(message, NamedTextColor.RED));
    }

    public void sendHomeNotFoundMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.HOME_NOT_FOUND);
        player.sendMessage(Component.text(message, NamedTextColor.RED));
    }

    public void sendHomeTpSetMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.WORLD_NOT_SET_TELEPORT);
        player.sendMessage(Component.text(message, NamedTextColor.YELLOW));
    }

    public void sendUserExistsMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.USER_EXISTS);
        player.sendMessage(Component.text(message, NamedTextColor.YELLOW));
    }

    public void sendTpSetSuccess(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.LOCAL_SET_SUCCESS);
        player.sendMessage(Component.text(message, NamedTextColor.GREEN));
    }

    public void sendNoHomeWorldMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.NO_HOME_WORLD);
        player.sendMessage(Component.text(message, NamedTextColor.YELLOW));
    }

    public void sendNotMyOwnMessage(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.NOT_MY_OWN);
        player.sendMessage(Component.text(message, NamedTextColor.YELLOW));
    }

    public void sendMaxHomePlayers(Player player) {
        Integer max = config.getInt(ConstantsAttribute.MAX_HOME_PLAYERS);
        String message = messageConfig.getString(ConstantsAttribute.MAX_HOME_PLAYERS_MESSAGE);
        String format = String.format(message, max);
        player.sendMessage(Component.text(format, NamedTextColor.YELLOW));
    }

    public void sendNoPermission(Player player) {
        String message = messageConfig.getString(ConstantsAttribute.NO_PERMISSION);
        player.sendMessage(Component.text(message, NamedTextColor.RED));
    }
}
